package com.example.JavaWeb1;

import com.alibaba.druid.pool.DruidDataSourceFactory;

import javax.sql.DataSource;
import java.io.InputStream;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.Properties;

public class Druid {
    private static DataSource data = null;
    static{
        InputStream is = ClassLoader.getSystemClassLoader().getResourceAsStream("Druid.properties");
        Properties pros = new Properties();
        try {
            pros.load(is);
            data = DruidDataSourceFactory.createDataSource(pros);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        Connection conn = null;
        try {
            conn = data.getConnection();
            System.out.println(conn);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }
    }
}
